<?php

class UsersResource extends SResource
{
    public function post()
    {
        try {
            $user = User::$objects->get_by_name($this->params['user']['name']);
            // le nom d'utilisateur est déjà pris
            $this->responds_error(409);
        } catch (SRecordNotFound $e) {
            $user = new User($this->params['user']);
            if ($user->save())
                $this->responds_nothing(201);
            else
                $this->responds_detailed_error($user->errors, 400);
        }
    }
}

?>